package org.huiway.huipicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.huiway.huipicturebackend.model.dto.picture.PictureUploadRequest;
import org.huiway.huipicturebackend.model.dto.user.ResetPasswordRequest;
import org.huiway.huipicturebackend.model.dto.user.UserQueryRequest;
import org.huiway.huipicturebackend.model.dto.user.UserRegisterRequest;
import org.huiway.huipicturebackend.model.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import org.huiway.huipicturebackend.model.vo.user.LoginUserVO;
import org.huiway.huipicturebackend.model.vo.user.UserSelfVO;
import org.huiway.huipicturebackend.model.vo.user.UserVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author hh
* @description 针对表【user(用户)】的数据库操作Service
* @createDate 2025-06-25 10:30:38
*/
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @param userRegisterRequest
     * @param multipartFile
     * @param pictureUploadRequest
     * @return
     */
    long userRegister(UserRegisterRequest userRegisterRequest, MultipartFile multipartFile, PictureUploadRequest pictureUploadRequest);

    /**
     * 获取加密后的密码
     * @param userPassword
     * @return
     */
    String getEncryptPassword(String userPassword);

    /**
     * 用户登录
     *
     * @param userAccount 用户账号
     * @param email  用户邮箱
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    LoginUserVO userLogin(String userAccount, String email, String userPassword, HttpServletRequest request);

    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 尝试获取当前登录用户（宽松模式，未登录返回null）
     * @param request
     * @return
     */
    User tryGetLoginUser(HttpServletRequest request);

    /**
     * 获取已登录用户信息（脱敏）
     *
     * @return
     */
    LoginUserVO getLoginUserVO(User user);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 获取脱敏‍后的单个用户信息
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    /**
     * 获取脱敏后的用户列表
     * @param userList
     * @return
     */

    List<UserVO> getUserVOList(List<User> userList);

    /**
     * 将查询请‍求转为 QueryWrapper 对象
     * @param userQueryRequest
     * @return
     */

    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(User user);

    /**
     * 用户修改自身信息（测试）
     * @param userSelfVO
     * @param pictureUploadRequest
     * @param multipartFile
     * @param user
     * @return
     */

    boolean updateUserSelf(UserSelfVO userSelfVO, PictureUploadRequest pictureUploadRequest, MultipartFile multipartFile, User user);

    /**
     * 重置密码
     * @param resetPasswordRequest
     * @param loginUser
     * @return
     */
    boolean resetPassword(ResetPasswordRequest resetPasswordRequest, User loginUser);
}
